def RunePriest_Limit2Powers(powerName):
	entry = List.SelectedEntry
	powersList = ['Thunderclap', 'Living Lightning', 'Storm Caller', 'Tempest\'s Wrath', 'Fury of the Wolf Spirits', 'Murderous Hurricane', 'Jaws of the World Wolf']
	selectedPowers = 1
	for power in powersList:
		if entry.Units[0].Equipment[power].Equipped:
			selectedPowers += 1
	entry.Units[0].Equipment[powerName].Equipped = True
	if selectedPowers > 2:
		for power in powersList:
			if powerName != power and entry.Units[0].Equipment[power].Equipped:
				selectedPowers -= 1
				entry.Units[0].Equipment[power].Equipped = False
				if selectedPowers == 2:
					break
	return False

def GreyHunter_CheckSpecials(weaponType):
	entry = List.SelectedEntry
	maxSpecials = 1
	if entry.Units.Count > 9:
		maxSpecials = 2
	actualSpecials = 0
	for unit in entry.Units:
		if unit.Equipment['Boltgun'].IsReplaced:
			actualSpecials += 1
	if actualSpecials >= maxSpecials:
	   for unit in entry.Units:
			if unit.Equipment['Boltgun'].IsReplaced and (maxSpecials == 1 or unit.Equipment['Boltgun'].Replacement.Equipment.Name != weaponType): #god this is ugly but you don't want it to remove a meltagun if you want to change flamer/meltagun to meltagun/meltagun
				unit.Equipment['Boltgun'].Reset()
				actualSpecials -= 1
				if actualSpecials < maxSpecials:
					break
	# make the second special weapon free
	if actualSpecials == 1:
		highestCost = unit.Equipment['Boltgun'].Replacements[weaponType].Cost
		for unit in entry.Units:
			if unit.Equipment['Boltgun'].IsReplaced:
				if unit.Equipment['Boltgun'].Replacement.Cost > highestCost:
					highestCost = unit.Equipment['Boltgun'].Replacement.Cost
				unit.Equipment['Boltgun'].Replacement.CostOffset = -1 * highestCost
				break
	return True

def WolfScout_CheckSpecials(weaponType):
	entry = List.SelectedEntry
	specialsList = ['Flamer', 'Heavy Bolter', 'Meltagun', 'Missile Launcher', 'Plasma Gun']
	maxSpecials = 1
	actualSpecials = 0
	for unit in entry.Units:
		if unit.Equipment['Bolt Pistol'].IsReplaced:
			for special in specialsList:
				if unit.Equipment['Bolt Pistol'].Replacement.Equipment.Name == special:
					actualSpecials += 1
					break
	if actualSpecials >= maxSpecials:
	   for unit in entry.Units:
			if unit.Equipment['Bolt Pistol'].IsReplaced and unit.Equipment['Bolt Pistol'].Replacement.Equipment.Name != weaponType:
				unit.Equipment['Boltgun'].Reset()
				actualSpecials -= 1
				if actualSpecials < maxSpecials:
					break
	return True

def WolfScout_CheckExtras(weaponType):
	entry = List.SelectedEntry
	maxSpecials = 2
	actualSpecials = 0
	for unit in entry.Units:
		if unit.Equipment['Plasma Pistol'].Equipped:
			actualSpecials += 1
		if unit.Equipment['Power Weapon'].Equipped:
			actualSpecials += 1
	if actualSpecials >= maxSpecials:
	   for unit in entry.Units:
			if weaponType == 'Plasma Pistol' and unit.Equipment['Power Weapon'].Equipped:
				unit.Equipment['Power Weapon'].Equipped = False
				actualSpecials -= 1
			if weaponType == 'Power Weapon' and unit.Equipment['Plasma Pistol'].Equipped:
				unit.Equipment['Plasma Pistol'].Equipped = False
				actualSpecials -= 1
			if actualSpecials < maxSpecials:
				break
	return True

def BloodClaw_CheckSpecials(weaponType):
	entry = List.SelectedEntry
	maxSpecials = 1
	if entry.Units.Count > 14:
		maxSpecials = 2
	actualSpecials = 0
	for unit in entry.Units:
		if unit.Name == "Lukas the Trickster":
			continue
		if unit.Equipment['Bolt Pistol'].IsReplaced:
			if unit.Equipment['Bolt Pistol'].Replacement.Equipment.Name == "Plasma Pistol":
				continue
			actualSpecials += 1
	if actualSpecials >= maxSpecials:
	   for unit in entry.Units:
			if unit.Name == "Lukas the Trickster":
				continue
			if unit.Equipment['Bolt Pistol'].IsReplaced and (maxSpecials == 1 or unit.Equipment['Bolt Pistol'].Replacement.Equipment.Name != weaponType): #god this is ugly but you don't want it to remove a meltagun if you want to change flamer/meltagun to meltagun/meltagun
				if unit.Equipment['Bolt Pistol'].Replacement.Equipment.Name == "Plasma Pistol":
					continue
				unit.Equipment['Bolt Pistol'].Reset()
				actualSpecials -= 1
				if actualSpecials < maxSpecials:
					break
	# make the second special weapon free
	if actualSpecials == 1:
		highestCost = unit.Equipment['Bolt Pistol'].Replacements[weaponType].Cost
		for unit in entry.Units:
			if unit.Name == "Lukas the Trickster":
				continue
			if unit.Equipment['Bolt Pistol'].IsReplaced:
				if unit.Equipment['Bolt Pistol'].Replacement.Equipment.Name == "Plasma Pistol":
					continue
				if unit.Equipment['Bolt Pistol'].Replacement.Cost > highestCost:
					highestCost = unit.Equipment['Bolt Pistol'].Replacement.Cost
				unit.Equipment['Bolt Pistol'].Replacement.CostOffset = -1 * highestCost
				break
	return True